<link rel="stylesheet" media="screen" type="text/css" href="<?php echo bu("css/datepicker.css"); ?>" />
<script type="text/javascript" src="<?php echo bu("js/datepicker.js"); ?>"></script>
<script>
		$(function() {
      $( "#datepicker" ).datepicker({
        changeMonth: true,
        changeYear: true,
        yearRange: '1900:2011',
        dateFormat: 'd MM yy',
      });
    });
</script>

<script>
  function verify(){
    var pass = document.forms["myForm"]["Users[password]"].value;
    var confirm = document.forms["myForm"]["Users[confirm_password]"].value;
    if((pass != confirm ) || (pass == '') || (confirm == '') ){
      alert("You must confirm your password correctly!");
      return false;
    }
    else{
      return true;
    }
  }
</script>

<script>
  $(document).ready(function(){
    $('#news-pagination ul li a').each(function(){
      var tmp = $(this).attr('href');
      $(this).attr('href', tmp+'#tabs-2');
    });

    $('#articles-pagination ul li a').each(function(){
      var tmp = $(this).attr('href');
      $(this).attr('href', tmp+'#tabs-3');
    });

    $('#webinars-pagination ul li a').each(function(){
      var tmp = $(this).attr('href');
      $(this).attr('href', tmp+'#tabs-4');
    });

    $('#download-pagination ul li a').each(function(){
      var tmp = $(this).attr('href');
      $(this).attr('href', tmp+'#tabs-5');
    });
  });
</script>

<script>
    function change_password()
    {
      $(".change").toggle();
    }

    function validation()
    {
      if($('#confirm_password').val() != $('#password').val() )
      {
        alert("You must confirm your password correctly!");
        return false;
      }

      return true;
    }
</script>

<div class='spacer'>&nbsp;</div>
<div id="tabs">
<ul>
	<li><a href="#tabs-1">Profile</a></li>
	<li><a href="#tabs-2">News & Content</a></li>
	<li><a href="#tabs-3">Journal</a></li>
	<li><a href="#tabs-4">Webinars</a></li>
	<li><a href="#tabs-5">Download</a></li>
</ul>

<span class="search-member">
    <form method="POST" action="<?php echo bu("search/members"); ?>">
      <input type="text" name="member" value="Search Members.." onClick="this.value= '';" />
    </form>
</span>

<div id="tabs-1" class='mainContainer tabs'>
	<h3>Edit Your Profile</h3><br />
  <?php
    $form = $this->beginWidget('CActiveForm', array(
      'action' => bu('profiles/update'),
      'htmlOptions' => array(
        'onSubmit' => 'javascript:return validation()',
      ),
    ));
  ?>
		<p>
			<label>School Name *</label>
			<?php echo $form->textField($user, 'name'); ?>
      <?php echo $form->error($user, 'name'); ?>
		</p>
		<p>
			<label>Email *</label>
			<?php echo $form->textField($user, 'email'); ?>
      <?php echo $form->error($user, 'email'); ?>
		</p>
		<p>
			<label>Address</label>
      <?php echo $form->textField($user, 'address'); ?>
			<?php echo $form->error($user, 'address'); ?>
		</p>
    <p class="change">
			<label>Password</label>
			<?php echo $form->passwordField($user, 'password', array('value' => '', 'id' => 'password')); ?>
      <?php echo $form->error($user, 'password'); ?>
		</p>
		<p class="change">
			<label>Confirm Password</label>
			<input type='password' name='confirm_password' id='confirm_password' />
		</p>
    <br />
    <a href="javascript:change_password();">Change Your Password</a>
		<div class='spacer'>&nbsp;</div>
		<hr />
		<span class='footnote'>* Must not be blank</span>
		<div class='spacer'>&nbsp;</div>

		<input type='submit' value='Save Changes' />
		<a class='normal' href='<?php echo bu("members/"); ?>'><input type='button' value='Back to Profile' /></a>
	<?php $this->endWidget(); ?>
</div>

<div id="tabs-2" class='tabs'>
    <a style="float:right; margin-right:10px;" href="<?php echo bu('news/rss/'.$_SESSION['member_id']); ?>"><img src="<?php echo bu('images/icons/rss.png'); ?>" style="width:20px;" /></a>
    <h3>News</h3><hr />
    <?php if($news){ ?>
      <?php foreach($news as $n){ ?>
      <div class='news'> <!-- Format the news view -->
        <div><a href='<?php echo bu("news/view/".$n->id); ?>'><img width="100px" src= '<?php echo bu("assets/news/".$n->image) ?>' align='left' /></a></div>
        <div>
          <h3><a href='<?php echo bu("news/view/".$n->id); ?>'><?php echo $n->subject; ?></a></h3>
          <div class='date'><?php echo Helpers::customDate($n->created_at); ?></div>
          <p><?php echo substr($n->content,0,540); ?></p>
        </div>
      </div>
      <?php } ?>
      <p style="float:right;"><a href="<?php echo bu("news?member=".$_SESSION['member_id']); ?>">Browse all news..</a></p>
    <?php }else{echo '<i>No contents yet.</i>';} ?>
    <br /><br />

    <a style="float:right; margin-right:10px;" href="<?php echo bu('articles/rss/'.$_SESSION['member_id']); ?>"><img src="<?php echo bu('images/icons/rss.png'); ?>" style="width:20px;" /></a>
    <h3>Articles</h3><hr />
    <?php if($articles){ ?>
      <?php foreach($articles as $article){ ?>
      <div class='news'> <!-- Format the news view -->
        <div><a href='<?php echo bu("articles/view/".$article->id); ?>'><img width="100px" src= '<?php echo bu("assets/articles/".$article->image) ?>' align='left' /></a></div>
        <div>
          <h3><a href='<?php echo bu("articles/view/".$article->id); ?>'><?php echo $article->subject; ?></a></h3>
          <div class='date'><?php echo Helpers::customDate($article->created_at); ?></div>
          <p><?php echo substr($article->content,0,540); ?></p>
        </div>
      </div>
      <?php } ?>
      <p style="float:right;"><a href="<?php echo bu("articles?member=".$_SESSION['member_id']); ?>">Browse all articles..</a></p>
    <?php }else{echo '<i>No contents yet.</i>';} ?>
    <br /><br />

    <a style="float:right; margin-right:10px;" href="<?php echo bu('links/rss/'.$_SESSION['member_id']); ?>"><img src="<?php echo bu('images/icons/rss.png'); ?>" style="width:20px;" /></a>
    <h3>Links</h3><hr />
    <?php if($links){ ?>
      <?php foreach($links as $link){ ?>
      <div class='news'> <!-- Format the news view -->
        <div>
          <h3><a href='<?php echo bu("links/view/".$link->id); ?>'><?php echo $link->title; ?></a></h3>
          <div class='date'><?php echo Helpers::customDate($link->created_at); ?></div>
          <p><?php echo substr($link->description,0,540); ?></p>
        </div>
      </div>
      <?php } ?>
      <p style="float:right;"><a href="<?php echo bu("links?member=".$_SESSION['member_id']); ?>">Browse all Links..</a></p>
    <?php }else{echo '<i>No contents yet.</i>';} ?>

</div>

<div id="tabs-3" class='tabs'>
  <?php if($journals){ ?>
    <?php foreach($journals as $journal){ ?>
    <div class='news'> <!-- Format the news view -->
      <div>
        <h3><a href='<?php echo bu("journals/download?id=".$journal->id); ?>'><?php echo $journal->title; ?></a></h3>
        <div class='date'><?php echo Helpers::customDate($journal->created_at); ?></div>
        <p><?php echo substr($journal->description,0,540); ?></p>
      </div>
    </div>
    <?php } ?>

    <div class='spacer'>&nbsp;</div><div class='spacer'>&nbsp;</div>
    <div id="articles-pagination" class="pagination">
      <?php
        $this->widget('CLinkPager',array(
          'pages'=>$journals_pages,
          "cssFile" => false,
          "header" => "",
        ));
      ?>
    </div>
  <?php }else{echo '<i>No contents yet.</i>';} ?>
</div>


<div id="tabs-4" class='tabs'>

  <?php if($webinars){ ?>
    <?php foreach($webinars as $webinar){ ?>
    <div class='news'> <!-- Format the news view -->
      <div>
        <h3><a href='<?php echo bu("webinar/view/".$webinar->id); ?>'><?php echo $webinar->subject; ?></a></h3>
        <div class='date'><?php echo Helpers::customDate($webinar->created_at); ?></div>
        <p><?php echo substr($webinar->content,0,540); ?></p>
      </div>
    </div>
    <?php } ?>

    <div class='spacer'>&nbsp;</div><div class='spacer'>&nbsp;</div>
    <div id="webinars-pagination" class="pagination">
      <?php
        $this->widget('CLinkPager',array(
          'pages'=>$webinars_pages,
          "cssFile" => false,
          "header" => "",
        ));
      ?>
    </div>
  <?php }else{echo '<i>No contents yet.</i>';} ?>
</div>


<div id="tabs-5" class='tabs'>
  <?php if($downloadUrls){ ?>
    <?php foreach($downloadUrls as $downloadUrl){ ?>
    <div class='news'> <!-- Format the news view -->
      <div>
        <h3><a href='<?php echo bu("downloadUrl/view/".$downloadUrl->id); ?>'><?php echo $downloadUrl->title; ?></a></h3>
        <div class='date'><?php echo Helpers::customDate($downloadUrl->created_at); ?></div>
        <p><?php echo substr($downloadUrl->description,0,540); ?></p>
      </div>
    </div>
    <?php } ?>

    <div class='spacer'>&nbsp;</div><div class='spacer'>&nbsp;</div>
    <div id="download-pagination" class="pagination">
      <?php
        $this->widget('CLinkPager',array(
          'pages'=>$downloadUrls_pages,
          "cssFile" => false,
          "header" => "",
        ));
      ?>
    </div>
  <?php }else{echo '<i>No contents yet.</i>';} ?>
</div>

</div>